Easy Menu Manager
Documentation
Thank you for purchasing my script. If you have any questions that are beyond the scope of this help file, please feel free to email via my user page contact form here:
http://codecanyon.net/user/gawibowo
Thanks so much!
Installation
Server Requirements:
- PHP: at least PHP 5.2
This application uses json_encode() function that was added in PHP 5.2. If you still use php 5.0.x or 5.1.x, you can use a third party script for json_encode(), for example this one.
- MySQL: at least MySQL 4.x
Upload Files
Extract the main zip file, and then upload the easymenu folder to your server.
Configuration File
Open config.php file and edit these values:
// Base URL
define('_BASE_URL', 'http://yoursite.com/easymenu/');
Change this with your url path of this application
// Database Connection Settings
define('DB_HOST', 'localhost');
define('DB_USER', 'root');
define('DB_PASS', 'password');
define('DB_NAME', 'easymenu');
Change this with your database settings (host, user, password, database name).
// Admin Login
define('ADMIN_USER', 'admin');
define('ADMIN_PASS', 'mypassword');
Change this with your username and password for accessing menu manager.
If you want to disable login, just fill the value with an empty string.
Database Setup
- Create a database in mysql, I suggest using phpMyAdmin.
- In your phpMyAdmin, type your database name in the Create new database field, and click Create.
- After database created, click on the Import menu, browse install directory, select easymm.sql (if you want to install database + sample data) or easymm-empty.sql (if you want to install database without sample data).
- Click Go to import the sql file.
- Your database should be installed now.
Database Structure
The database has 2 tables: menu and menu_group.
-
menu (7 fields):
-
id: the ID of the menu, added automatically.
-
parent_id: the "parent" ID of the menu. If a menu is in top level, the value of this field should be 0.
-
title: the title of the menu.
-
url: the url of the menu. can be full url (with http prefix) or relative url.
-
class: the class attribute of the <li> element. With a class attribute, the menu can be styled easily, for example if you want to add an icon beside the menu title.
-
position: this field is for ordering menu. The menu should be ordered based on the group and this field.
-
group_id: the ID of the menu group this menu belongs to.
-
menu_group (2 fields):
-
id: the ID of the menu group, added automatically.
-
title: the title of the menu group.
If you rename the tables or fields, you must change the table and field names configuration in the config.php
// Tables Settings
define('MENU_TABLE', 'menu');
define('MENUGROUP_TABLE', 'menu_group');
// Fields Settings
define('MENU_ID', 'id');
define('MENU_PARENT', 'parent_id');
define('MENU_TITLE', 'title');
define('MENU_URL', 'url');
define('MENU_CLASS', 'class');
define('MENU_POSITION', 'position');
define('MENU_GROUP', 'group_id');
Directory and File Structure
-
includes: for classes/libraries and functions
-
db.php: class for database operations
-
functions.php: for global functions
-
tree.php: class for generating nested lists
-
install: contains sql files. Can be deleted if your application has been installed.
-
modules: for controller files
-
home.php: controller for showing menu preview
-
menu.php: controller for menu manager
-
menu_group.php: controller for menu group actions
-
user.php: controller for login and logout user
-
templates: for template/view files
-
css: this directory contains 4 css files:
-
home.css: used in public preview, contains styles for dropdown menu (horizontal and vertical)
-
login.css: used in login form
-
reset.css: css reset file
-
style.css: used in menu manager
-
images: directory for storing images
-
js: this directory contains 5 javascript files:
-
html5.js: to enable html 5 in IE browser
-
interface-1.2.js & inestedsortable.js: jQuery nested sortables plugin
-
jquery.1.4.1.min.js: jQuery javascript framework
-
menu.js: scripts for menu manager
-
home.php: view for public preview
-
login.php: view for login form
-
menu.php: view for menu manager
-
menu_edit.php: view for edit menu form
-
menu_group_add.php: view for add menu group form
- config.php: configuration file
- index.php: the front controller
URL Structure
This application uses a framework with this url structure:
index.php?act=controller.method
controller is the name of the file in the modules directory
method is the method inside the controller file
For example: index.php?act=news.detail&id=1
This url means the application will search file in modules/news.php, and the method detail inside this file will be executed
PHP Libraries
These are the php class libraries used in this application:
DB
This is the class for database operations.
Some code example:
include _DOC_ROOT . 'includes/db.php';
$db = new DB;
//connect to database
$db->Connect('localhost', 'root', 'pass', 'dbname');
//execute a delete query
$db->Execute("DELETE FROM account WHERE id = 15");
//get multi rows result from a SELECT query, return an array
$data = $db->GetAll("SELECT * FROM account LIMIT 10");
print_r($data);
//get one result from a SELECT query, return a string
$name = $db->GetOne("SELECT name FROM account WHERE id = 1");
echo $name;
//get one row result from a SELECT query, return an array
$row = $db->GetRow("SELECT username, password, name FROM account WHERE id = 1");
print_r($row);
//get one column from a SELECT query, return an array
$username = $db->GetCol("SELECT username FROM account ORDER BY id LIMIT 10");
print_r($username);
//quick insert from an array data
$data['username'] = 'myusername';
$data['password'] = '123456';
$data['name'] = 'My Name';
$data = $db->insert('account', $data);
//quick update from an array data
$data['username'] = 'user';
$data['password'] = 'admin';
$data['name'] = 'My Real Name';
$data = $db->update('account', $data, 'id = 1');
Tree
This is the class for generating html nested lists.
Some code example:
include _DOC_ROOT . 'includes/tree.php';
$tree = new Tree;
$tree->add_row(1, 0, '', 'Menu 1');
$tree->add_row(2, 0, '', 'Menu 2');
$tree->add_row(3, 1, '', 'Menu 1.1');
$tree->add_row(4, 1, '', 'Menu 1.2');
echo $tree->generate_list();
Output:
<ul>
<li>Menu 1
<ul>
<li>Menu 1.1</li>
<li>Menu 1.2</li>
</ul>
</li>
<li>Menu 2</li>
</ul>
Sources and Credits
I've used the following scripts and icons: